package com.corechina.apex_osswords.domain.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corechina.apex_osswords.domain.entity.CorePollingPlan;
import com.corechina.apex_osswords.domain.vo.CorePollingPlanVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 巡检计划表 Mapper 接口
 * </p>
 *
 * @author cc
 * @since 2023-03-09
 */
@Component
public interface CorePollingPlanMapper extends BaseMapper<CorePollingPlan> {

    @Delete("delete from core_polling_plan where parent_id = #{pollingId} and status = 0")
    int deleteByPollingId(@Param("pollingId") Integer pollingId);

    @Update("update core_polling_plan set plan_person = #{planPerson} where parentId = #{pollingId} and status = 0")
    int updatePlanPersonByPollingId(@Param("planPerson") Integer planPerson, @Param("pollingId") Integer pollingId);

    @Select("select id from core_polling_plan where parent_id = #{pollingId} and status = 0")
    List<Integer> getPlanListByPollingId(@Param("pollingId") Integer pollingId);

    IPage<CorePollingPlanVo> getList(Page page, @Param("abnormal") Integer abnormal, @Param("pollingId") Integer pollingId, @Param("enterpriseId") Integer enterpriseId, @Param("status") Integer status, @Param("planPersonName") String planPersonName, @Param("planPerson") Integer planPerson, @Param("isToday") Integer isToday, @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    IPage<CorePollingPlanVo> getListByProjectIdForWeiXin(Page page, @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("projectId") Integer projectId, @Param("status") Integer status, @Param("enterpriseId") Integer enterpriseId);

    CorePollingPlanVo getOne(@Param("id") Integer id);

    @Update("update core_polling_plan set status = #{status} where id = #{id}")
    int updateStatus(@Param("status") Integer status, @Param("id") Integer id);

}
